package controller

import (
	"context"
	v1 "tFilm4/api/v1"
	"tFilm4/internal/model"
	"tFilm4/internal/service"
)

type cMovieOrder struct{}

var MovieOrder = cMovieOrder{}

func (c *cMovieOrder) CreateMovieOrder(ctx context.Context, req *v1.CreateMovieOrderReq) (res *v1.CreateMovieOrderRes, err error) {
	err = service.MovieOrder().CreateMovieOrder(ctx, model.CreateMovieOrderInput{
		UserId:      req.UserId,
		SessionId:   req.SessionId,
		MovieName:   req.MovieName,
		MovieImage:  req.MovieImage,
		TotalPrice:  req.TotalPrice,
		SelectTable: req.SelectTable,
	})
	return
}

func (c *cMovieOrder) GetMovieOrderByUserId(ctx context.Context, req *v1.GetMovieOrderByUserIdReq) (res *v1.GetMovieOrderByUserIdRes, err error) {
	count, infos, err := service.MovieOrder().GetMovieOrderByUserId(ctx, req.UserId)
	res = &v1.GetMovieOrderByUserIdRes{
		OrderInfos: infos,
		Count:      count,
	}
	return
}
func (c *cMovieOrder) GetMovieOrderById(ctx context.Context, req *v1.GetMovieOrderByIdReq) (res *v1.GetMovieOrderByIdRes, err error) {
	info, err := service.MovieOrder().GetMovieOrderById(ctx, req.OrderId)
	res = &v1.GetMovieOrderByIdRes{
		OrderInfo: &info,
	}
	return
}
